/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Ivan Ivic
 */
public class Server {
    private ServerSocket sSocket;

    public Server() {
        try {
            sSocket = new ServerSocket(9000);
            System.out.println("Server pokrenut na portu " + sSocket.getLocalPort());
        } catch (IOException ex) {
            Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public ServerSocket getsSocket() {
        return sSocket;
    }

    public static void main(String[] args)
    {
        Server server = new Server();
        try
        {
            while (true)
            {
                ServerThread thread = new ServerThread(server.getsSocket().accept());
                thread.start();
            }
        }        
        catch (IOException e)
        {
            e.printStackTrace();
        }       
    }
}
